package com.witmed.service.impl;

import java.util.List;
import java.util.Map;

import com.witmed.dao.AppointmentOperationDao;
import com.witmed.dao.impl.AppointmentOperationDaoImpl;
import com.witmed.entity.Appointment;
import com.witmed.entity.Department;
import com.witmed.entity.Doctor;
import com.witmed.entity.Hospital;
import com.witmed.service.AppointmentOperationService;
import com.witmed.util.PageInfo;

/**
 * AppointmentOperationService接口类的实现类
 * 
 * @author ChenYouming
 *
 */
public class AppointmentOperationServiceImpl implements AppointmentOperationService {
	AppointmentOperationDao appointmentOperationDao = new AppointmentOperationDaoImpl();

	/**
	 * 
	 * 通过关键字模糊分页查询医生
	 * 
	 * @param typeId
	 *            关键字类型
	 * @param keyword
	 *            关键字
	 * @param pagNum
	 *            页码
	 * @param pageSize
	 *            每页显示的记录数
	 * @return 返回一个医生的分页工具类
	 */
	@Override
	public PageInfo<Doctor> searchByDoctorNameOrDepatmentNameOrhosptialName(int typeId, String keyword, int pagNum,
			int pageSize) {
		keyword ="%"+keyword+"%";
		PageInfo<Doctor> doctorData = appointmentOperationDao.searchByDoctorNameOrDepatmentNameOrhosptialName(typeId,
				keyword, pagNum, pageSize);

		return doctorData;
	}

	/**
	 * 多条件组合查询分页所有
	 * 
	 * @param map
	 *            用于存放前端传的条件值
	 * @return 返回一个医生的分页工具类
	 */
	@Override
	public PageInfo<Doctor> searchByhosptialNameOrDepatmentNameOrDoctorNameAll(Map<String, Object> map) {
		PageInfo<Doctor> pageInfo = appointmentOperationDao.searchByhosptialNameOrDepatmentNameOrDoctorNameAll(map);
		return pageInfo ;
	}

	 /**
	  * 查询所有医院
	  * @return 返回医院集合
	  */
	@Override
	public List<Hospital> findHospital() {
		List<Hospital> list = appointmentOperationDao.findHospital();
		return list;
	}
	/**
	  * 查询所有科室
	  * @return 返回科室集合
	  */
	@Override
	public List<Department> findDepartment() {
		List<Department> list = appointmentOperationDao.findDepartment();
		return list;
	}
	/**
	 * 查询预约时间
	  * @return 返回预约时间集合
	 * @param time  时间
	 * @param doctorId   医生编号
	 * 
	 */
	  
	@Override
	public List<Appointment> findAppointment(String time ,int doctorId) {
		List<Appointment> list = appointmentOperationDao.findAppointment(time, doctorId);
		
		return list;
	}

	/**
	 * 新增预约时间表数据
	 * @param appointment 
	 * @return 影响行数
	 */
	@Override
	public boolean insert(Appointment appointment) {
		
		return appointmentOperationDao.insert(appointment) == 1 ? true :false;
	}

	/**
	 * 修改预约时间表数据
	 * @param appointment
	 * @return  影响行数
	 */
	@Override
	public boolean update(Appointment appointment) {
		// TODO Auto-generated method stub
		return appointmentOperationDao.update(appointment) == 1 ? true:false;
	}

	/**
	 * 删除预约时间表数据
	 * @param appointmentid 预约时间id
	 * @return  影响行数
	 */
	@Override
	public boolean delete(int appointmentid) {
		// TODO Auto-generated method stub
		return appointmentOperationDao.delete(appointmentid) == 1 ? true : false;
	}

	@Override
	public List<Appointment> getFindAppointment(int appointmentId) {
		// TODO Auto-generated method stub
		return appointmentOperationDao.findAppointment(appointmentId);
	}

	@Override
	public boolean updateDoctor(Appointment appointment) {
		// TODO Auto-generated method stub
		return appointmentOperationDao.updateDoctor(appointment)==1 ? true : false;
	}

}
